<template>
<div>
    <div class="e-table billList">
        <div class="top">
            <div class="left">
                <div class="listTop">
                    <el-button
                        size="small"
                        class="btn-greenYellow"
                        @click="openAddDialog"
                    >
                        新增</el-button
                    >
                </div>
            </div>
            <div class="right">
                <div class="right-div1">
                    <el-input
                        placeholder="请输入关键字"
                        size="small"
                        v-model="pagination.keyword"
                        @blur="search"
                    >
                        <i slot="suffix" class="el-input__icon el-icon-search" @click="search"></i>
                    </el-input>
                </div>
                <div>
                    <el-button
                        size="small"
                        style="background: #2e61d7; color: #fff"
                        @click="heightSharch"
                        >高级搜索
                    </el-button>
                </div>
            </div>
        </div>
        <el-table
            ref="table"
            class="table"
            :data="tableData"
            border
            style="width: 100%"
            highlight-current-row
            height="0"
            v-sortTable="{ 'tableData': tableData, '_this': this, 'ref': 'table' }"
        >
            <el-table-column label="姓名" min-width="200"
                show-overflow-tooltip class-name="blue-column">
                <template slot-scope="{ row }" >
                    <span @click="tableDbShow(row)">{{row.operator}}</span>
                </template>
            </el-table-column>
            <el-table-column
                prop="gender"
                label="性别"
                width="100"
            >
                <template slot-scope="{ row }">
                    <span>{{ ['女','男'][row.gender] }}</span>
                </template>
            </el-table-column>
            <el-table-column
                prop="idCard"
                label="身份证号"
                min-width="200"
                show-overflow-tooltip
            >
            </el-table-column>
            <el-table-column
                prop="assessmentFraction"
                label="考核分数"
                width="150"
            >
            </el-table-column>
            <el-table-column
                prop="billDate"
                label="考核时间"
                width="150"
            >
            </el-table-column>
            <el-table-column
                prop="orgName"
                label="考核机构"
                align="center"
                min-width="200"
                show-overflow-tooltip>
            </el-table-column>
        </el-table>
        <ComPagination
            :total="totalPage"
            :pageSize.sync="pagination.limit"
            :currentPage.sync="pagination.page"
            @currentChange="listByEntity"
            @sizeChange="listByEntity"
            class="bottomSetting"
        />
        <!-- mask -->
    </div>
</div>
</template>

<script>
import request from '@/api/equip/operatorManagement.js'
import ComPagination from '@/components/pagination/pagination.vue'
import { mapState } from 'vuex'
import { vueDom, debounce, advanceSearch } from '@/utils/common.js'
export default {
    data () {
        return {
            tableData: [],
            MouseEnterId: 0,
            dialogVisibleSearch: false,
            pagination: {
                'endDate': '',
                'keyword': '',
                'limit': 20,
                'name': '',
                'orgId': localStorage.getItem('searchOrgId'),
                'page': 1,
                'starDate': '',
                'states': []
            },
            totalPage: 0, //总页数
            tableHeight: 0,
        }
    },
    components: {
        ComPagination
    },
    computed: {
        ...mapState({
            workStatus: state=>state.equip.equipData.workStatus,
            assessmentLevel: state=>state.equip.equipData.assessmentLevel,
        })
    },
    created () {
        this.getList()
    },
    mounted () {
        // table动态高度
        vueDom(
            () => {
                this.tableHeight = document.body.clientHeight - 170
            },
            () => {
                return $('table').length !== 0
            }
        )
        this.fn = () => {
            this.tableHeight = document.body.clientHeight - 170
        }
        window.onresize = debounce(this.fn)
    },
    methods: {
        //获取列表
        getList () {
            request.operatorAssessList(this.pagination).then(res=>{
                this.tableData = res.list
                this.totalPage = res.totalCount
            })
        },
        //分页查询
        listByEntity () {
            this.getList()
        },
        //模糊搜索
        search () {
            this.getList()
        },
        //清空高级搜索的数据
        clearData () {
            this.pagination = {
                'assessmentLevel': [],
                'idCard': '',
                'keyword': '',
                'limit': 10,
                'name': '',
                'operatingRange': '',
                'orgId': '',
                'page': 1,
                'phoneNo': '',
                'states': [],
                'workStatus': []
            }
            this.setSearchData({ equipSearchData: this.pagination })
        },
        heightSharch () {
            advanceSearch('/operatorHeightSearch').then(res => {
                this.pagination = res.equipSearchData
                this.getList()
                this.clearData()
            })
        },
        //新增
        openAddDialog () {
            this.$router.push('/operatorAssessAdd')
        },
        //查看
        tableDbShow (row) {
            this.$router.push({
                path: '/operatorAssessEdit',
                query: { billid: row.billId }
            })
        },
    }
}
</script>

<style lang="scss" scoped>
::v-deep.el-steps--simple{
    background: #eff2f6;
    margin-bottom: 10px;
}
</style>
